package com.general.framework.sqlGroup;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

class Promotion {
    private int promotion_type;
    // 构造函数
    public Promotion(int promotion_type) {
        this.promotion_type = promotion_type;
    }
    public int getPromotion_type() {
        return promotion_type;
    }
}

public class Main {
    public static void main(String[] args) {
        List<Promotion> promotions = new ArrayList<>();
        promotions.add(new Promotion(1));
        promotions.add(new Promotion(2));
        promotions.add(new Promotion(1));
        promotions.add(new Promotion(3));
        int i = promotions.hashCode();
        System.out.println(i);

        // 使用Collectors.groupBy进行分组
        Map<Integer, List<Promotion>> groupedPromotions = promotions.stream()
                .collect(Collectors.groupingBy(Promotion::getPromotion_type));
        System.out.println(groupedPromotions);
    }
}